#include <iostream>
using namespace std;

class Fruit
{
public:
    virtual void sayName() = 0;

};

class FuitFactory
{
public:
    virtual Fruit* getFuit() = 0;
};

class Banana : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "Banana\n" << endl;
    }

};

class BananaFactory: public FuitFactory
{
public:
    virtual Fruit* getFuit()
    {
        return new Banana();
    }
};

class Apple : public Fruit
{
public:
    virtual void sayName()
    {
        cout << "Apple\n" << endl;
    }

};
class AppleFactory : public FuitFactory
{
public:
    virtual Fruit* getFuit()
    {
        return new Apple();
    }
};
int main2()
{
    FuitFactory* factory = NULL;
    Fruit* fruit = NULL;

    factory = new BananaFactory();
    fruit = factory->getFuit();
    fruit->sayName();
  
    delete factory;
    delete fruit;

    factory = new AppleFactory();
    fruit = factory->getFuit();
    fruit->sayName();

    delete factory;
    delete fruit;



    system("pause");
    return 0;
}